package com.kbs.im.client.bootstrap;

import com.kbs.im.client.handler.DeviceRegisterResponseHandler;
import com.kbs.im.client.handler.HeartBeatTimerHandler;
import com.kbs.im.client.handler.ListAllDeviceResponseHandler;
import com.kbs.im.common.protocol.codec.PacketCodecHandler;
import com.kbs.im.common.protocol.codec.Spliter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioSocketChannel;

/**
 * 客户端pipline配置类
 *
 * @author zhangzhang
 */
public class ImClientChannelInitializer extends ChannelInitializer<NioSocketChannel> {

    static final ImClientChannelInitializer INSTANCE = new ImClientChannelInitializer();


    @Override
    protected void initChannel(NioSocketChannel ch) throws Exception {
        //消息魔数校验
        ch.pipeline().addLast(new Spliter());
        //自定义协议的编解码器
        ch.pipeline().addLast(PacketCodecHandler.INSTANCE);
//        ch.pipeline().addLast(new TestHandler());
        ch.pipeline().addLast(new DeviceRegisterResponseHandler());
        ch.pipeline().addLast(new ListAllDeviceResponseHandler());
        ch.pipeline().addLast(new HeartBeatTimerHandler());
    }
}
